# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.DigitalAssetLinks.V1.Model.Statement do
  @moduledoc """
  Describes a reliable statement that has been made about the relationship between a source asset and a target asset. Statements are always made by the source asset, either directly or by delegating to a statement list that is stored elsewhere. For more detailed definitions of statements and assets, please refer to our [API documentation landing page](/digital-asset-links/v1/getting-started).

  ## Attributes

  *   `relation` (*type:* `String.t`, *default:* `nil`) - The relation identifies the use of the statement as intended by the source asset's owner (that is, the person or entity who issued the statement). Every complete statement has a relation. We identify relations with strings of the format `/`, where `` must be one of a set of pre-defined purpose categories, and `` is a free-form lowercase alphanumeric string that describes the specific use case of the statement. Refer to [our API documentation](/digital-asset-links/v1/relation-strings) for the current list of supported relations. Example: `delegate_permission/common.handle_all_urls` REQUIRED
  *   `relationExtensions` (*type:* `map()`, *default:* `nil`) - Statements may specify relation level extensions/payloads to express more details when declaring permissions to grant from the source asset to the target asset. These relation extensions should be specified in the `relation_extensions` object, keyed by the relation type they're associated with. { relation: ["delegate_permission/common.handle_all_urls"], target: {...}, relation_extensions: { "delegate_permission/common.handle_all_urls": { ...handle_all_urls specific payload specified here... } } } When requested, and specified in the statement file, the API will return relation_extensions associated with the statement's relation type. i.e. the API will only return relation_extensions specified for "delegate_permission/common.handle_all_urls" if this statement object's relation type is "delegate_permission/common.handle_all_urls".
  *   `source` (*type:* `GoogleApi.DigitalAssetLinks.V1.Model.Asset.t`, *default:* `nil`) - Every statement has a source asset. REQUIRED
  *   `target` (*type:* `GoogleApi.DigitalAssetLinks.V1.Model.Asset.t`, *default:* `nil`) - Every statement has a target asset. REQUIRED
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :relation => String.t() | nil,
          :relationExtensions => map() | nil,
          :source => GoogleApi.DigitalAssetLinks.V1.Model.Asset.t() | nil,
          :target => GoogleApi.DigitalAssetLinks.V1.Model.Asset.t() | nil
        }

  field(:relation)
  field(:relationExtensions, type: :map)
  field(:source, as: GoogleApi.DigitalAssetLinks.V1.Model.Asset)
  field(:target, as: GoogleApi.DigitalAssetLinks.V1.Model.Asset)
end

defimpl Poison.Decoder, for: GoogleApi.DigitalAssetLinks.V1.Model.Statement do
  def decode(value, options) do
    GoogleApi.DigitalAssetLinks.V1.Model.Statement.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.DigitalAssetLinks.V1.Model.Statement do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
